define(function(require, exports, module){
	require("resource/js/easyui/easyloader.js");
	require("resource/js/easyui/themes/icon.css");
	require.async("resource/js/component/rules.js");
	var A = require('resource/js/component/ajax.js');
	var EC = require("resource/js/component/easycombobox.js");
	EC.create({
		url:BASEPATH+"/base/authoriza/basecode/getType.htm",
		param:{checkeds:"sex"}
	});
	var initForm = function(){
		$("#userupd").form({
			url:BASEPATH+"/base/authoriza/user/updateSelfBase.htm",
			success:function(data){
	    		if(indexApp) indexApp.exec("initUser");
			}
		});
		$("#btn-save").click(function(){
			$("#userupd").form("submit");
		});
	}

	$("#rtn-reset").click(function(){
		$("#userupd").form('clear' );
	});

//	获取用户头像
	var initUser = function(){
		EC.init({ ele:"#sex", grouptype:"sex"});
		A.init().success(function(code,msg,data){
			$("#userupd").form("load",data);
//			$("#userIcon").attr("src",BASEPATH+data.userImg);
		}).post(BASEPATH+"/base/authoriza/user/getCurUser.htm");
		

		/*$("#userIcon").click(function(){
			$("#userImg").upload("show");
		});*/
		/*$("#userImg").upload({
	    	title:""+Obj.get('base.common.success.Headchoose')+"",
	    	param:{exts:"png,jpg,bmp,jif"},
	    	onSuccessAfter:function(files){
	    		$("#userImg").val(files[0].fileUrl);
	    		$("#userIcon").attr("src",BASEPATH+files[0].fileUrl);
	    	}
	    });*/
		
	}
//修改头像
	
	/*$("#userIcon").on("click",function(e){
	    EU.init({
	    	title:"头像选择",
	    	param:{exts:"png,jpg,bmp,jif"},
	    	onSuccessAfter:function(files){
	    		$("#userImg").val(files[0].fileUrl);
	    		$("#userIcon").attr("src",BASEPATH+files[0].fileUrl);
	    	}
	    }).show();
	});	*/
	//
	
//提交
	$("#btn-save").bind("click",function(){
		using(["form"],function(){
			if($("#userupd").form("validate")){
				var req_data = $("#userupd").serializeJson();
				console.log(req_data);
				A.init().success(function(code,msg,data){
					/*using(['messager'],function(){
						$.messager.alert('系统提示',msg, 'info',function(){
							$("#rtn-back").click();
						});
					})*/
					$.messager.show({
						title:'',
						msg:msg+'!',
						timeout:5000,
						showType:'slide'
					});
					window.parent.indexApp.exec("initUser");
				}).error(function(code,msg,data){
						using(['messager'],function(){
							$.messager.alert(""+Obj.get('base.common.success.Systemprompt')+"",msg);
						});
				}).contentType("application/json").post(BASEPATH+"/base/authoriza/user/update.htm",JSON.stringify(req_data));
			}
		});
	});
	exports.init=function(){
		using(["textbox","form","combobox","upload"],function(){
			initUser();
		});
	}	
});



















